home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Oct 90 / MacApp.Tech$ 10⁄5⁄90 / 2074-MacAppPa next >
Encoding:
Text File  |  1991-03-06  |  1.4 KB  |  54 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File MacAppPatch.a
  3. ;
  4. ;    Written by Mike Lockwood, September, 1990
  5. ;
  6. ;
  7. ;    To build, execute these lines in MPW:
  8. ;
  9. ;    asm MacAppPatch.a
  10. ;    link MacAppPatch.a.o -o MacAppPatch -rt INIT=0 -t INIT -c '????'
  11.  
  12.  
  13.                         INCLUDE    'Traps.a'
  14.                         
  15. MAIN            PROC        EXPORT
  16.                 bra.s        InstallPatch        ; jump to patch installation
  17. PatchBegin
  18.                 move.l        4(sp),a0            ; Get ControlHandle
  19.                 move.l        a0,-(sp)            ; Put it on the stack for the real Draw1Control
  20.                 _HLock                            ; Lock ControlHandle
  21.                 move.l        oldTrapAddr,a0        ; Get Addr of real Draw1Control
  22.                 jsr            (a0)                ; Execute it
  23.                 move.l        4(sp),a0            ; Get ControlHandle
  24.                 _HUnlock                        ; Unlock it
  25.                 move.l        (sp)+,a0            ; Get return address
  26.                 addq        #4,sp                ; Clean up stack
  27.                 jmp            (a0)                ; return
  28. oldTrapAddr        DC.L        0                    ; address of real Draw1Control
  29. PatchEnd
  30.  
  31. InstallPatch    
  32.                 move        #$16D,d0
  33.                 _GetTrapAddress    newTool            ; Get trap address for Draw1Control
  34.                 lea            oldTrapAddr,a1        ; save it in oldTrapAddr
  35.                 move.l        a0,(a1)
  36.                 
  37.                 move.l        #(PatchEnd-PatchBegin),d4
  38.                 move.l        d4,d0
  39.                 _NewPtr        sys                    ; Allocate storage for patch in System heap
  40.                 move.l        a0,a1
  41.                 move.l        a1,a4
  42.                 lea            PatchBegin,a0
  43.                 move.l        d4,d0
  44.                 _BlockMove                        ; Copy patch to the System heap
  45.                 
  46.                 move        #$16D,d0
  47.                 move.l        a4,a0
  48.                 _SetTrapAddress    newTool            ; Set trap address for Draw1Control
  49.                 
  50.                 rts                                ; INIT done!
  51.                 
  52.                 ENDP
  53.                 
  54.                 END.